package cn.itsource.order.controller;

import cn.itsource.order.service.IOrderAdoptService;
import cn.itsource.user.domain.User;
import cn.itsource.utils.AjaxResult;
import cn.itsource.utils.LoginContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
// 多对一   一对多  多对多


@RestController
@RequestMapping("/adopt")
public class AdoptController {

    @Autowired
    private IOrderAdoptService orderAdoptService;

    @PostMapping
    public AjaxResult createOrder(@RequestBody Map<String,String> map, HttpServletRequest request){
        User user = (User)LoginContext.getCurrent(request);

        String result = orderAdoptService.createOrder(map, user);

        return  AjaxResult.me().setResultObj(result);
    }
}
